package com.itheima.controller.backend.security;

import com.itheima.common.entity.Result2;
import com.itheima.pojo.vo.BusinessVo;
import com.itheima.pojo.vo.MemberVo;
import com.itheima.pojo.vo.SetmealVo;
import com.itheima.service.ReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
@Slf4j
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private ReportService reportService;

    /**
     * 会员数量统计
     * @return
     */
    @GetMapping("/getMemberReport")
    public Result2 getMemberReport() {
        MemberVo memberVo =reportService.getMemberReport();
        return new Result2(true,"会员数量查询成功",memberVo);
    }

    /**
     * 获取套餐占比统计数据
     * @return
     */
    @GetMapping("/getSetmealReport")
    public Result2 getSetmealReport() {

       SetmealVo setmealVo = reportService.getSetmealReport();

        return new Result2(true,"套餐占比查询成功",setmealVo);
    }

    /**
     * 获取运营数据统计
     * @return
     */
    @GetMapping("/getBusinessReportData")
    public Result2 getBusinessReportData() {
        BusinessVo businessVo = reportService.getBusinessReportData();
        return new Result2(true,"运营数据查询成功",businessVo);
    }

    /**
     * 导出运营数据统计
     * @return
     */
    @GetMapping("/exportBusinessReport")
    public Result2 exportBusinessReport(HttpServletResponse response) throws IOException {

        reportService.exportBusinessReport(response);
        return new Result2(true,"导出成功");
    }
}
